package com.syn.vr.control;

import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.CompoundButton;

import com.gaoyi.basemodule.baseControl.BaseView;
import com.syn.vr.R;
import com.syn.vr.databinding.ViewTitleSwitchBinding;

public class TitleSwitchView extends BaseView<ViewTitleSwitchBinding> {

    public TitleSwitchView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void initView(TypedArray ta) {
        String title = ta.getString(R.styleable.TitleSwitchView_title_switch_text);
        if (!TextUtils.isEmpty(title)) {
            mBinding.switchTitleTv.setText(title);
        }
    }

    public void setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener onCheckedChangeListener) {
        mBinding.switchTitle.setOnCheckedChangeListener(onCheckedChangeListener);
    }

    public void setChecked(boolean checked) {
        mBinding.switchTitle.setChecked(checked);
    }

    public boolean isChecked() {
        return mBinding.switchTitle.isChecked();
    }

    @Override
    protected ViewTitleSwitchBinding getViewBinding() {
        return ViewTitleSwitchBinding.inflate(LayoutInflater.from(mContext), this, false);
    }

    @Override
    protected int[] getAttrs() {
        return R.styleable.TitleSwitchView;
    }
}
